package cn.kgc.ubagnet.service.cart;

import cn.kgc.ubagnet.mapper.CartMapper;
import cn.kgc.ubagnet.mapper.CartProMapper;
import cn.kgc.ubagnet.pojo.Cart;
import cn.kgc.ubagnet.pojo.CartPro;
import cn.kgc.ubagnet.pojo.CartProExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class CartServiceImpl implements CartService{
    @Resource
    CartProMapper cartpromapper;
    @Resource
    CartMapper cartMapper;
    //查询用户的购物车
    @Override
    public List<CartPro> CarttProList(Integer userid) {
        CartProExample example=new CartProExample();
        example.createCriteria().andUseridEqualTo(userid);
        List<CartPro> cartProList=cartpromapper.selectByExample(example);
        return cartProList;
    }
    //添加到购物车
    @Override
    public int AddCart(Cart cart) {
        return cartMapper.insertSelective(cart);
    }
}
